import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)
//懒加载
var base = resolve => {
  require.ensure(['../pages/Index/Base.vue'], () => {
    resolve(require('../pages/Index/Base.vue'))
  })
}

var login = resolve => {
  require.ensure(['../pages/Login/Index.vue'], () => {
    resolve(require('../pages/Login/Index.vue'))
  })
}
var home = resolve => {
    require.ensure(['../pages/Home'], () => {
      resolve(require('../pages/Home'))
    })
  }
  var error = resolve => {
    require.ensure(['../pages/Error'], () => {
      resolve(require('../pages/Error'))
    })
  }
  var goodlist = resolve => {
    require.ensure(['../pages/Goods/GoodList.vue'], () => {
      resolve(require('../pages/Goods/GoodList.vue'))
    })
  }
  var goodpush = resolve => {
    require.ensure(['../pages/Goods/GoodPush.vue'], () => {
      resolve(require('../pages/Goods/GoodPush.vue'))
    })
  }
  var goodkind = resolve => {
    require.ensure(['../pages/Goods/GoodKind.vue'], () => {
      resolve(require('../pages/Goods/GoodKind.vue'))
    })
  }

  var orderlist = resolve => {
    require.ensure(['../pages/Order/List.vue'], () => {
      resolve(require('../pages/Order/List.vue'))
    })
  }

  var ordcancel = resolve => {
    require.ensure(['../pages/Order/Cancel.vue'], () => {
      resolve(require('../pages/Order/Cancel.vue'))
    })
  }

  var customerlist = resolve => {
    require.ensure(['../pages/Customer/List.vue'], () => {
      resolve(require('../pages/Customer/List.vue'))
    })
  }
  var findcode = resolve => {
    require.ensure(['../pages/Customer/FindCode.vue'], () => {
      resolve(require('../pages/Customer/FindCode.vue'))
    })
  }
  var shopconfig = resolve => {
    require.ensure(['../pages/ShopConfig/List.vue'], () => {
      resolve(require('../pages/ShopConfig/List.vue'))
    })
  }
  var wxconfig = resolve => {
    require.ensure(['../pages/Config/WxConfig.vue'], () => {
      resolve(require('../pages/Config/WxConfig.vue'))
    })
  }
  var ReportedLoss = resolve => {
    require.ensure(['../pages/Drp/ReportedLoss.vue'], () => {
      resolve(require('../pages/Drp/ReportedLoss.vue'))
    })
  }
  var TransferCargo = resolve => {
    require.ensure(['../pages/Drp/TransferCargo.vue'], () => {
      resolve(require('../pages/Drp/TransferCargo.vue'))
    })
  }
  var Inventory = resolve => {
    require.ensure(['../pages/Drp/Inventory.vue'], () => {
      resolve(require('../pages/Drp/Inventory.vue'))
    })
  }
  var PutInStorage = resolve => {
    require.ensure(['../pages/Drp/PutInStorage.vue'], () => {
      resolve(require('../pages/Drp/PutInStorage.vue'))
    })
  }
  var detial = resolve => {
    require.ensure(['../pages/Drp/Detial.vue'], () => {
      resolve(require('../pages/Drp/Detial.vue'))
    })
  }
  var booking = resolve => {
    require.ensure(['../pages/Drp/Booking.vue'], () => {
      resolve(require('../pages/Drp/Booking.vue'))
    })
  }
  var Sales = resolve => {
    require.ensure(['../pages/Drp/Sales.vue'], () => {
      resolve(require('../pages/Drp/Sales.vue'))
    })
  }
  var admin = resolve => {
    require.ensure(['../pages/Config/admin.vue'], () => {
      resolve(require('../pages/Config/admin.vue'))
    })
  }
  var coulist = resolve => {
    require.ensure(['../pages/Coupon/CouList.vue'], () => {
      resolve(require('../pages/Coupon/CouList.vue'))
    })
  }
  var coutime = resolve => {
    require.ensure(['../pages/Coupon/CouTime.vue'], () => {
      resolve(require('../pages/Coupon/CouTime.vue'))
    })
  }

  var coushare = resolve => {
    require.ensure(['../pages/Coupon/CouShare.vue'], () => {
      resolve(require('../pages/Coupon/CouShare.vue'))
    })
  }
  var coulimit = resolve => {
    require.ensure(['../pages/Coupon/CouLimit.vue'], () => {
      resolve(require('../pages/Coupon/CouLimit.vue'))
    })
  }
  var payconfig = resolve => {
    require.ensure(['../pages/Pay/PayConfig.vue'], () => {
      resolve(require('../pages/Pay/PayConfig.vue'))
    })
  }
  var index = resolve => {
    require.ensure(['../pages/Index/Index.vue'], () => {
      resolve(require('../pages/Index/Index.vue'))
    })
  }

//路由
var routers = new Router({
  routes: [
    {
      path: '/',
      redirect: '/Index'
    }, 
    {
      path: '/Login',
      component: login,
    },
    {
        path: '/error',
        component: error,
    },
    {
      path: '/Base',
      component: base,
      meta: {requestauth:true},
      children:[
        {
          path:'/Index',
          meta: {requestauth:true},
          component: index,
        },
        {
            path:'/Home',
            meta: {requestauth:true},
            component: home,
        },
        {
            path:'/GoodList',
            meta: {requestauth:true},
            component: goodlist,
        },
        {
          path:'/GoodPush',
          meta: {requestauth:true},
          component: goodpush,
        },
        {
          path:'/GoodKind',
          meta: {requestauth:true},
          component: goodkind,
        },
        {
          path:'/OrderList',
          meta: {requestauth:true},
          component: orderlist,
        },
        {
          path:'/OrderCancel',
          meta: {requestauth:true},
          component: ordcancel,
        },
        {
          path:'/CustomerList',
          meta: {requestauth:true},
          component: customerlist,
        },
        {
          path:'/FindCode',
          meta: {requestauth:true},
          component: findcode,
        },
        {
          path:'/ShopConfig',
          meta: {requestauth:true},
          component: shopconfig,
        },
        {
          path:'/WxConfig/wxw',
          meta: {requestauth:true},
          component: wxconfig,
        },
        {
          path:'/WxConfig/xcxt',
          meta: {requestauth:true},
          component: wxconfig,
        },
        // {
        //   path:'/xcxconfig',
        //   meta: {requestauth:true},
        //   component: xcxconfig,
        // },
        {
          path:'/ReportedLoss',
          meta: {requestauth:true},
          component: ReportedLoss,
        },
        {
          path:'/TransferCargo',
          meta: {requestauth:true},
          component: TransferCargo,
        },
        {
          path:'/Inventory',
          meta: {requestauth:true},
          component: Inventory,
        },
        {
          path:'/PutInStorage',
          meta: {requestauth:true},
          component: PutInStorage,
        },
        {
          path:'/Detial',
          meta: {requestauth:true},
          component: detial,
        },
        {
          path:'/Booking',
          meta: {requestauth:true},
          component: booking,
        },
        {
          path:'/Sales',
          meta: {requestauth:true},
          component: Sales,
        },
        {
          path:'/Admin',
          meta: {requestauth:true},
          component: admin,
        },
        {
          path:'/CouList',
          meta: {requestauth:true},
          component: coulist,
        },
        {
          path:'/CouTime',
          meta: {requestauth:true},
          component: coutime,
        },
        {
          path:'/CouShare',
          meta: {requestauth:true},
          component: coushare,
        },
        {
          path:'/CouLimit',
          meta: {requestauth:true},
          component: coulimit,
        },
        {
          path:'/PayConfig',
          meta: {requestauth:true},
          component: payconfig,
        }
      ]
    },
    {
        path:'*',
        component:error,
    }
  ]
})

export default routers